package filter;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class PathMatcher {
    public static boolean match(String pattern, String path) {
        // 将Ant风格通配符转换为正则表达式
        pattern = pattern.replace("*", ".*");
        pattern = pattern.replace("?", ".");
        pattern = "^" + pattern + "$";
        Pattern regex = Pattern.compile(pattern);
        Matcher matcher = regex.matcher(path);
        return matcher.matches();
    }
}